<template>
    <div id="seachDialog">
      <a-modal
      title="快速筛选"
      width="550px"
      :visible="searchData.show"
      @cancel="handleClose">
        <el-row style="padding:30px 70px 50px 20px;overflow-y:auto;width:540px;overflow-x:hidden;">
            <el-form ref="searchParames" :model="searchParames" label-width="120px">
                <el-form-item label="状态:">
                    <el-select style="width:100%" size="small" filterable v-model="searchParames.contactStatus" placeholder="请选择">
                        <el-option v-for="(item,index) in rototStatusDate" :key="index" :label="item.desc" :value="item.name"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="联系人:">
                    <el-input clearable size="small" v-model="searchParames.contacts" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="负责人:">
                    <el-input clearable size="small" v-model="searchParames.director" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="联系电话:">
                    <el-input clearable size="small" v-model="searchParames.contactNumber" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="负责人:">
                    <el-input clearable size="small" v-model="searchParames.contacts" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="客户反馈:">
                    <el-input clearable size="small" v-model="searchParames.feedback" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="下次跟进时间:">
                    <el-date-picker
                    style="width:100%"
                    size="small"
                    clearable
                    v-model="searchParames.nextFollowDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="地区:">
                    <el-input size="small" clearable v-model="searchParames.area" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="签单时间:">
                    <el-date-picker
                    style="width:100%"
                    size="small"
                    clearable
                    value-format="yyyy-MM-dd"
                    v-model="searchParames.signingDate"
                    type="date"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-form>
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="handleReset">重置</el-button>
            <el-button size="small" type="primary" @click="handleSend">查询</el-button>
        </span>
      </a-modal>
    </div>
</template>

<script>
import department from '../../components/department'
export default {
    props: ['searchData'],
    data() {
        return {
          searchParames: {
            contacts: '', //联系人
            director: '', //负责人
            contactNumber: '', //联系电话
            contactStatus: '', //状态（枚举）
            feedback: '', //客户反馈
            nextFollowDate: '', // 下次跟进时间
            area: '', //地区
            signingDate: '' //签单时间
          },
          rototStatusDate: []
        };
    },
    methods: {
        handleSend () {
            let searchDate = []
            for(var key in this.searchParames){
                if (this.searchParames[key]) {
                    if (key == 'signingDate' || key == 'nextFollowDate') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'date'
                        })
                    } else if (key == 'contactStatus') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'enumeration'
                        })
                    } else {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'string'
                        })
                    }
                }
            }
            this.$emit('checkSearch',searchDate)
            this.handleClose()
        },
        handleClose () {
            this.searchData.show = false
        },
        handleReset () {
            this.searchParames.contacts = '' //联系人
            this.searchParames.contactNumber = '' //联系电话
            this.searchParames.contactStatus = '' //状态（枚举）
            this.searchParames.feedback = '' //客户反馈
            this.searchParames.nextFollowDate = '' // 下次跟进时间
            this.searchParames.area = '' //地区
            this.searchParames.signingDate = '' //签单时间
            this.searchParames.director = ''
            this.$emit('resetSearch')
            this.$refs.searchParames.resetFields()
        }
    },
    computed: {
      changeDialog () {
        return this.searchData.show
      }
    }, 
    watch: {
      changeDialog: {
        handler (curVal, oldVal) {
          if (curVal) {
            this.searchParames.contacts = this.searchData.contacts
            this.$utils.getEnumberation('postEcRobotContactStatus','rototStatusDate',this) //状态
          } else {
          }
        }
      }
    },
};
</script>

<style>
#seachDialog .el-dialog{
    padding-bottom: 0; 
    overflow-x: hidden;
}
#seachDialog .el-dialog__footer{
    border-top: #f4f4f4 solid 1px;
}
</style>
